# -*- coding: utf-8 -*-
"""
API文档定义
"""

SIMPLE_DOC = {
    "tags": ["活动管理"],
    "summary": "API接口",
    "description": "API接口说明",
    "responses": {
        "200": {
            "description": "请求成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "操作成功"},
                    "data": {"type": "object"}
                }
            }
        }
    }
}


SIMPLE_DOC = {
    "tags": ["API"],
    "summary": "API接口",
    "description": "API接口说明",
    "responses": {
        "200": {
            "description": "请求成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "操作成功"},
                    "data": {"type": "object"}
                }
            }
        }
    }
}

# 为兼容性创建通用别名
CREATE_ORDER_DOC = SIMPLE_DOC
GET_ORDER_LIST_DOC = SIMPLE_DOC
GET_ORDER_DETAIL_DOC = SIMPLE_DOC
UPDATE_ORDER_DOC = SIMPLE_DOC
DELETE_ORDER_DOC = SIMPLE_DOC
CANCEL_ORDER_DOC = SIMPLE_DOC
GET_USER_ORDERS_DOC = SIMPLE_DOC

# 管理员相关
ADMIN_GET_ORDER_LIST_DOC = SIMPLE_DOC
ADMIN_UPDATE_ORDER_DOC = SIMPLE_DOC
ADMIN_DELETE_ORDER_DOC = SIMPLE_DOC
ADMIN_ORDER_STATS_DOC = SIMPLE_DOC

# 活动相关
CREATE_ACTIVITY_DOC = SIMPLE_DOC
GET_ACTIVITY_LIST_DOC = SIMPLE_DOC
GET_ACTIVITY_DETAIL_DOC = SIMPLE_DOC
UPDATE_ACTIVITY_DOC = SIMPLE_DOC
DELETE_ACTIVITY_DOC = SIMPLE_DOC
JOIN_ACTIVITY_DOC = SIMPLE_DOC

# 支付相关
CREATE_PAYMENT_DOC = SIMPLE_DOC
PAYMENT_NOTIFY_DOC = SIMPLE_DOC
GET_PAYMENT_STATUS_DOC = SIMPLE_DOC

# 横幅相关
GET_BANNER_LIST_DOC = SIMPLE_DOC
CREATE_BANNER_DOC = SIMPLE_DOC
UPDATE_BANNER_DOC = SIMPLE_DOC
DELETE_BANNER_DOC = SIMPLE_DOC

# 管理员相关
ADMIN_LOGIN_DOC = SIMPLE_DOC
GET_ADMIN_INFO_DOC = SIMPLE_DOC

# 仪表盘相关
GET_DASHBOARD_STATS_DOC = SIMPLE_DOC
GET_REVENUE_CHART_DOC = SIMPLE_DOC
GET_ORDER_CHART_DOC = SIMPLE_DOC

# 其他可能缺失的活动相关
LEAVE_ACTIVITY_DOC = SIMPLE_DOC
CHECKIN_ACTIVITY_DOC = SIMPLE_DOC

# 获取活动列表接口文档
GET_ACTIVITY_LIST_DOC = {
    "tags": ["活动管理"],
    "summary": "获取活动列表",
    "description": "获取活动列表，支持分页和状态筛选",
    "parameters": [
        {
            "name": "page",
            "in": "query",
            "type": "integer",
            "required": False,
            "description": "页码，从1开始",
            "example": 1,
            "default": 1
        },
        {
            "name": "per_page",
            "in": "query",
            "type": "integer",
            "required": False,
            "description": "每页数量，最大50",
            "example": 10,
            "default": 10
        },
        {
            "name": "status",
            "in": "query",
            "type": "string",
            "required": False,
            "description": "活动状态筛选：open=开放报名，closed=报名截止，cancelled=已取消",
            "example": "open"
        }
    ],
    "responses": {
        "200": {
            "description": "获取活动列表成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "活动列表数据",
                        "properties": {
                            "activities": {
                                "type": "array",
                                "description": "活动列表",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "id": {"type": "integer", "example": 1, "description": "活动ID"},
                                        "title": {"type": "string", "example": "篮球友谊赛", "description": "活动标题"},
                                        "description": {"type": "string", "example": "欢迎大家参加篮球比赛", "description": "活动描述"},
                                        "organizer_id": {"type": "integer", "example": 1, "description": "组织者ID"},
                                        "venue_id": {"type": "integer", "example": 1, "description": "场馆ID"},
                                        "start_time": {"type": "string", "example": "2024-01-15 09:00:00", "description": "开始时间"},
                                        "end_time": {"type": "string", "example": "2024-01-15 11:00:00", "description": "结束时间"},
                                        "registration_deadline": {"type": "string", "example": "2024-01-14 18:00:00", "description": "报名截止时间"},
                                        "max_participants": {"type": "integer", "example": 20, "description": "最大参与人数"},
                                        "current_participants": {"type": "integer", "example": 5, "description": "当前参与人数"},
                                        "status": {"type": "string", "example": "open", "description": "活动状态"},
                                        "created_at": {"type": "string", "example": "2024-01-01 12:00:00", "description": "创建时间"},
                                        "venue": {
                                            "type": "object",
                                            "description": "场馆信息",
                                            "properties": {
                                                "id": {"type": "integer", "example": 1},
                                                "name": {"type": "string", "example": "中央篮球场"},
                                                "address": {"type": "string", "example": "北京市朝阳区体育馆路1号"}
                                            }
                                        }
                                    }
                                }
                            },
                            "total": {"type": "integer", "example": 25, "description": "总记录数"},
                            "page": {"type": "integer", "example": 1, "description": "当前页码"},
                            "pages": {"type": "integer", "example": 3, "description": "总页数"}
                        }
                    }
                }
            }
        }
    }
}

# 获取活动详情接口文档
GET_ACTIVITY_DETAIL_DOC = {
    "tags": ["活动管理"],
    "summary": "获取活动详情",
    "description": "获取活动详细信息，包括组织者、参与者和场馆信息",
    "parameters": [
        {
            "name": "activity_id",
            "in": "path",
            "type": "integer",
            "required": True,
            "description": "活动ID",
            "example": 1
        }
    ],
    "responses": {
        "200": {
            "description": "获取活动详情成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {
                        "type": "integer",
                        "example": 200,
                        "description": "状态码"
                    },
                    "message": {
                        "type": "string",
                        "example": "获取成功",
                        "description": "响应消息"
                    },
                    "data": {
                        "type": "object",
                        "description": "活动详细信息",
                        "properties": {
                            "id": {"type": "integer", "example": 1, "description": "活动ID"},
                            "title": {"type": "string", "example": "篮球友谊赛", "description": "活动标题"},
                            "description": {"type": "string", "example": "欢迎大家参加篮球比赛", "description": "活动描述"},
                            "organizer_id": {"type": "integer", "example": 1, "description": "组织者ID"},
                            "venue_id": {"type": "integer", "example": 1, "description": "场馆ID"},
                            "start_time": {"type": "string", "example": "2024-01-15 09:00:00", "description": "开始时间"},
                            "end_time": {"type": "string", "example": "2024-01-15 11:00:00", "description": "结束时间"},
                            "registration_deadline": {"type": "string", "example": "2024-01-14 18:00:00", "description": "报名截止时间"},
                            "max_participants": {"type": "integer", "example": 20, "description": "最大参与人数"},
                            "current_participants": {"type": "integer", "example": 5, "description": "当前参与人数"},
                            "status": {"type": "string", "example": "open", "description": "活动状态"},
                            "view_count": {"type": "integer", "example": 100, "description": "浏览次数"},
                            "created_at": {"type": "string", "example": "2024-01-01 12:00:00", "description": "创建时间"},
                            "is_participant": {"type": "boolean", "example": False, "description": "当前用户是否已参与"},
                            "can_join": {"type": "boolean", "example": True, "description": "当前用户是否可以加入"},
                            "organizer": {
                                "type": "object",
                                "description": "组织者信息",
                                "properties": {
                                    "id": {"type": "integer", "example": 1},
                                    "nickname": {"type": "string", "example": "张三"},
                                    "avatar_url": {"type": "string", "example": "https://example.com/avatar.jpg"}
                                }
                            },
                            "venue": {
                                "type": "object",
                                "description": "场馆信息",
                                "properties": {
                                    "id": {"type": "integer", "example": 1},
                                    "name": {"type": "string", "example": "中央篮球场"},
                                    "address": {"type": "string", "example": "北京市朝阳区体育馆路1号"},
                                    "type": {"type": "string", "example": "basketball"}
                                }
                            },
                            "participants": {
                                "type": "array",
                                "description": "参与者列表",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "id": {"type": "integer", "example": 1},
                                        "user_id": {"type": "integer", "example": 2},
                                        "joined_at": {"type": "string", "example": "2024-01-10 15:30:00"},
                                        "user": {
                                            "type": "object",
                                            "properties": {
                                                "id": {"type": "integer", "example": 2},
                                                "nickname": {"type": "string", "example": "李四"},
                                                "avatar_url": {"type": "string", "example": "https://example.com/avatar2.jpg"}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "404": {
            "description": "活动不存在",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 404},
                    "message": {"type": "string", "example": "活动不存在"}
                }
            }
        }
    }
}

# 加入活动接口文档
JOIN_ACTIVITY_DOC = {
    "tags": ["活动管理"],
    "summary": "加入活动",
    "description": "用户加入活动，会自动检查黑名单限制",
    "parameters": [
        {
            "name": "activity_id",
            "in": "path",
            "type": "integer",
            "required": True,
            "description": "活动ID",
            "example": 1
        }
    ],
    "responses": {
        "200": {
            "description": "加入活动成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "成功加入活动"},
                    "data": {
                        "type": "object",
                        "properties": {
                            "participant_id": {"type": "integer", "example": 1, "description": "参与记录ID"},
                            "joined_at": {"type": "string", "example": "2024-01-15 10:30:00", "description": "加入时间"}
                        }
                    }
                }
            }
        },
        "400": {
            "description": "加入失败",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 400},
                    "message": {"type": "string", "example": "活动已满员"}
                }
            }
        },
        "403": {
            "description": "被拉黑无法加入",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 403},
                    "message": {"type": "string", "example": "您已被活动组织者拉黑，无法加入此活动"}
                }
            }
        }
    }
}

# 退出活动接口文档
LEAVE_ACTIVITY_DOC = {
    "tags": ["活动管理"],
    "summary": "退出活动",
    "description": "用户退出已加入的活动",
    "parameters": [
        {
            "name": "activity_id",
            "in": "path",
            "type": "integer",
            "required": True,
            "description": "活动ID",
            "example": 1
        }
    ],
    "responses": {
        "200": {
            "description": "退出活动成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "成功退出活动"}
                }
            }
        },
        "400": {
            "description": "退出失败",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 400},
                    "message": {"type": "string", "example": "您未参加此活动"}
                }
            }
        }
    }
}

# 创建活动接口文档（管理员）
CREATE_ACTIVITY_DOC = {
    "tags": ["活动管理"],
    "summary": "创建活动",
    "description": "创建新的活动",
    "parameters": [
        {
            "name": "body",
            "in": "body",
            "required": True,
            "description": "活动创建参数",
            "schema": {
                "type": "object",
                "required": ["title", "venue_id", "start_time", "end_time", "max_participants"],
                "properties": {
                    "title": {
                        "type": "string",
                        "description": "活动标题",
                        "example": "篮球友谊赛"
                    },
                    "description": {
                        "type": "string",
                        "description": "活动描述",
                        "example": "欢迎大家参加篮球比赛"
                    },
                    "venue_id": {
                        "type": "integer",
                        "description": "场馆ID",
                        "example": 1
                    },
                    "start_time": {
                        "type": "string",
                        "description": "开始时间，格式：YYYY-MM-DD HH:MM:SS",
                        "example": "2024-01-15 09:00:00"
                    },
                    "end_time": {
                        "type": "string",
                        "description": "结束时间，格式：YYYY-MM-DD HH:MM:SS",
                        "example": "2024-01-15 11:00:00"
                    },
                    "registration_deadline": {
                        "type": "string",
                        "description": "报名截止时间，格式：YYYY-MM-DD HH:MM:SS",
                        "example": "2024-01-14 18:00:00"
                    },
                    "max_participants": {
                        "type": "integer",
                        "description": "最大参与人数",
                        "example": 20
                    }
                }
            }
        }
    ],
    "responses": {
        "200": {
            "description": "创建活动成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "活动创建成功"},
                    "data": {
                        "type": "object",
                        "properties": {
                            "activity_id": {"type": "integer", "example": 1, "description": "活动ID"},
                            "title": {"type": "string", "example": "篮球友谊赛", "description": "活动标题"}
                        }
                    }
                }
            }
        }
    }
}

# 更新活动接口文档（管理员）
UPDATE_ACTIVITY_DOC = {
    "tags": ["活动管理"],
    "summary": "更新活动",
    "description": "更新活动信息",
    "responses": {
        "200": {
            "description": "更新成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "活动更新成功"}
                }
            }
        }
    }
}

# 删除活动接口文档（管理员）
DELETE_ACTIVITY_DOC = {
    "tags": ["活动管理"],
    "summary": "删除活动",
    "description": "删除活动",
    "responses": {
        "200": {
            "description": "删除成功",
            "schema": {
                "type": "object",
                "properties": {
                    "code": {"type": "integer", "example": 200},
                    "message": {"type": "string", "example": "活动删除成功"}
                }
            }
        }
    }
}
